package cn.devzyh.oms.wsms.api.converter;

import cn.devzyh.oms.wsms.api.entity.Stock;
import cn.devzyh.oms.wsms.api.vo.StockVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import java.util.HashMap;
import java.util.Map;

@Mapper
public interface StockConverter {

	StockConverter INSTANCE = Mappers.getMapper(StockConverter.class);

	@Mapping(target = "createBy", ignore = true)
	@Mapping(target = "createTime", ignore = true)
	@Mapping(target = "updateBy", ignore = true)
	@Mapping(target = "updateTime", ignore = true)
	@Mapping(target = "delFlag", ignore = true)
	Stock toStock(Map<String, String> map);

	default Map<String, String> toStringMap(Stock stock) {
		Map<String, String> map = new HashMap<>();
		map.put("id", stock.getId().toString());
		map.put("warehouseCode", stock.getWarehouseCode());
		map.put("channelCode", stock.getChannelCode());
		map.put("skuCode", stock.getSkuCode());
		map.put("location", stock.getLocation());
		map.put("quantity", stock.getQuantity().toString());
		map.put("version", stock.getVersion().toString());
		return map;
	}

	StockVO toStockVO(Stock stock);

}
